using Game.Main.Model;
using UnityEngine;

namespace Game.Component
{
	public class BoardEraserItem : BaseItem
	{
		private float width;

		private float height;

		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
			if (coll != null)
			{
				width = coll.size.x;
				height = coll.size.y;
			}
		}

		public override void TouchMove(TouchEventData touchEventData)
		{
			base.TouchMove(touchEventData);
			if (!(coll != null))
			{
				return;
			}
			RaycastHit2D[] array = Physics2D.RaycastAll(touchEventData.curPos, Vector2.zero, 15f, 512);
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].collider != null)
				{
					BaseItem component = array[i].collider.transform.parent.GetComponent<BaseItem>();
					if (component != null && component.itemData.scriptType == 2)
					{
						((PaintBoardItem)component).Eraser(new Vector2(base.transform.position.x - width / 2f, base.transform.position.y), new Vector2(base.transform.position.x + width / 2f, base.transform.position.y + height));
						break;
					}
				}
			}
		}
	}
}
